// TOWN SCRIPT
//    Town 2: Rocky coast

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documentation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

body;

beginstate INIT_STATE;
// Called upon entering
//Scenario introduction text.
if(get_flag(2,0) == 0) {
	reset_dialog();
	add_dialog_str(0,"The heavy drumming of rain, like a thousand fingertips on your cheek, wakes you. Slowly, painfully, you get to your feet and brush yourself off.",0);
	add_dialog_str(1,"The last thing you remember is steering your small boat too close to an unchartered island before hitting a bunch of rocks. The strong winds had carried you a little further than you intended to go and the currents quickly took over...",0);
	add_dialog_str(2,"Amazingly though, you survived - after realising you were going down you steered right for the island, but a strong gust struck, knocking you into more rocks and throwing you overboard.",0);
	add_dialog_str(3,"Yet you were lucky and here you are - soaking wet and on an empty island, but safe. For now. Still aching from your journey through the crashing ocean, you look around for shelter.",0);
	run_dialog(1);
	
	reset_dialog();
	add_dialog_str(0,"As you turn around to the east you spot something you weren't quite expecting... a small building - built of stone, and intact. It looks old, but sturdy and well-built.",0);
	add_dialog_str(1,"Weird - the island isn't marked as inhabited on your maps - that was why you moved closer for a look in the first place. You wonder who lives here, and more importantly, if they're friendly.",0);
	run_dialog(1);
	set_flag(2,0,1);
}
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// Called every turn.
break;

//Mushrooms in SW
beginstate 10;
if(get_flag(2,1) == 0) {
		if(get_skill_total(14) < 5) {
			message_dialog("There is a small patch of herbs growing here - you take a look and spot a type that you know are useful for making healing potions.","You carefully take them, being careful not to damage them, and pack them away. Unfortunately nothing else in the patch looks useful.");
			set_flag(2,1,1);
			reward_give(214);
			end();
		}
		if(get_skill_total(14) < 10) {
			message_dialog("There is a small patch of herbs growing here - you take a look and spot two bunches of a herb you know is useful for making healing potions.","You carefully take them, being careful not to damage them, and pack them away. Unfortunately nothing else in the patch looks useful.");
			set_flag(2,1,1);
			reward_give(214);
			reward_give(214);
			end();
		}
		if(get_skill_total(14) > 10) {
			message_dialog("There is a small patch of herbs growing here - you take a look and spot two bunches of a herb you know is useful for making healing potions and a few toadstools.","You carefully take them, being careful not to damage them, and pack them away. Unfortunately nothing else in the patch looks useful.");
			set_flag(2,1,1);
			reward_give(214);
			reward_give(214);
			reward_give(218);
			end();
		}
	} else {
		message_dialog("You've already searched this patch- there is nothing else here that is both useful and fully grown. You leave it be.","");
		end();
	}
break;
	
//Poison shrooms
beginstate 11;
	if(get_flag(2,2) == 0) {
		message_dialog("There is a small patch of mushrooms growing here, beneath the shelter of a willow tree. You take a closer look at them, hoping to find something useful, either for alchemy or for food.","Fortunately you know enough about plants to know that the kinds of mushroom growing here are quite toxic. Not wanting to poison yourself, you leave them be.");
		set_flag(2,2,1);
	} else {
		message_dialog("These mushrooms are still poisonous, and will continue to be so forever. You leave them be.","");
	}
break;

//Entering the cottage/building
beginstate 12;
	if(get_flag(2,3) == 0) {
		reset_dialog();
		add_dialog_str(0,"You enter the building cautiously, not wanting to alarm any potential occupants. However, you quickly see that the place is empty - and probably has been for some time.",0);
		add_dialog_str(1,"The floor is dusty and free from footprints and the bookshelves across the room are empty - only a few mouldy sheets of parchment survive; blown to the floor by a breeze let in by a flimsy curtain.",0);
		add_dialog_str(2,"A large cauldron and a lingering stench of mandrake immediately identify the place as an apothecarist's workshop, but what grabs your attention is a large tome at the far end of the room, seemingly intact.",0);
		add_dialog_str(3,"Perhaps it has information about the people who lived here - and where they went...",0);
		run_dialog(1);
		set_flag(2,3,1);
		set_terrain(29,15,441);
	}
break;


//Bedroom
beginstate 13;
	if(get_flag(2,4) == 0) {
		message_dialog("This must have been the bedroom for whoever lived here - two beds are pushed against the far wall, still tidily made up. The rest of the room though, could do with a good clean.","As well as the dust and dirt collected on the floor, the festering remains of a meal sit rotting on the table. Still, if you needed to rest for a while, in here would be much better than outside...");
		set_flag(2,4,1);
	}
break;

//South box
beginstate 14;
	if(get_flag(2,5) == 0) {
		message_dialog("This stone chest is full of threadbare clothes, ratty blankets and broken tools. Needless to say, none of it is of any use to you. You close the chest and move on.","");
		set_flag(2,5,1);
		block_entry(1);
	} else {
		message_dialog("You have already looked in here.","");
		block_entry(1);
	}
break;	

//North box
beginstate 15;
	if(get_flag(2,6) == 0) {
		reset_dialog();
		add_dialog_str(0,"This stone chest is mostly full of broken vials and twisted spoons. However, tucked away at the bottom, wrapped in a dirty old cloth, you find a small flask.",0);
		add_dialog_str(1,"The label has worn off but a quick taste confirms that it is a mild healing potion, and there's enough left for a couple of uses. Do you take it with you?",0);
		add_dialog_choice(0,"Yes, take the flask.");
		add_dialog_choice(1,"No, leave it alone.");
		if(run_dialog(1) == 1) {
			message_dialog("You take the flask, and close the chest behind you.","");
			reward_give(220);
			reward_give(220);
			set_flag(2,6,1);
			end();
		} else {
			message_dialog("You put the flask back - although it seems to be alright still, it has been locked away for a very long time - the last thing you need now is a bad reaction to a strange potion.","You close the chest and move on.");
			end();
		}
	}
break;


//Pedestal
beginstate 16;
	if(get_flag(2,7) == 0) {
		reset_dialog();
		add_dialog_str(0,"You approach the tome on the pedestal which, fortunately, seems to have survived its time here. Flicking through it, you discover that large chunks of text are illegible; damaged by water.",0);
		add_dialog_str(1,"However, there is a page, about half-way in, which is still intact. It has one sentence on it, written in shaky handwriting, taking up the entire sheet of paper:",0);
		add_dialog_str(2,"_Beware the angels._",0);
		add_dialog_str(3,"You look around nervously, but there still isn't anybody around. You close the book, and move on.",0);
		run_dialog(1);
		set_flag(2,7,1);
	} else {
		message_dialog("You open the book again, and it falls open onto the page it was on before: _Beware the angels._","Unsettled, you flick through it again, but you don't find anything else interesting. Closing the book, you move on.");
	}
break;

//Beds
beginstate 17;
	reset_dialog();
	add_dialog_str(0,"You approach the beds. If you needed to rest they look comfortable and sturdy enough to get the job done, and you wouldn't be out in the rain...",0);
	add_dialog_str(1,"Do you wish to rest?",0);
	add_dialog_choice(0,"Yes, get some rest.");
	add_dialog_choice(1,"No, move on.");
	if(run_dialog(1) == 1) {
		play_sound(-96);
		message_dialog("You brush the dust off the beds and lie down. Surprisingly, the beds are comfortable and damp-free. You quickly fall asleep.","A few hours later you wake up, refreshed and ready for action.");
		revive_party();
		end();
	} else {
		message_dialog("You decide against sleeping on the old, probably mouldy beds, and move on.","");
	}
break;

//OH NO ANGEL
beginstate 18;
	if(get_flag(2,3) == 1) {
		if(get_flag(2,8) == 0) {
			reset_dialog();
			add_dialog_str(0,"Suddenly you stop. On the road ahead you spot a statue, shaped like an angel. It is facing you, but has its eyes covered. You approach it slowly, keeping your eyes on it, trying to remember if it was there before.",0);
			add_dialog_str(1,"You turn around, to look back at the coast, and when you turn back, the angel has vanished, as if into thin air. But... that's impossible!",0);
			if(get_flag(2,7) == 0) {
			add_dialog_str(2,"You look around again trying to spot it, thinking that somebody must have moved it whilst you had your back turned, but it's as if the statue was never there...",0);
			}		
			if(get_flag(2,7) == 1) {
				add_dialog_str(3,"You look around again trying to spot it, but it's as if the statue were never there. As you try to make sense of it, you recall what you saw in the book just now - _Beware the angels_...",0);
				add_dialog_str(4,"Letting your hands rest on your weapons you move on, alert and watchful.",0);
			}
			run_dialog(1);
			set_terrain(29,15,0);
			set_flag(2,8,1);
			}
	} else {
		message_dialog("You should explore the building before continuing down the road.","");
		block_entry(1);
	}
break;

//Exiting
beginstate 19;
	if(get_flag(2,9) == 0) {
		reset_dialog();
		add_dialog_str(0,"As you continue down this path it strikes you that you haven't heard any birdsong, or seen any wild animals during your short time here; in fact, you've seen no sign at all that there is anything alive on the island.",0);
		add_dialog_str(1,"It's not even as if they've died, either; there are no bones or corpses. It's as if they've just... vanished.",0);
		add_dialog_str(2,"There is somebody on the island though - you're sure of it - the angel you saw just now couldn't have moved on its own, which means somebody placed it there, and then took it away.",0);
		add_dialog_str(3,"You wonder who it was though, and why? Perhaps you'll find answers somewhere else. Hopefully, you'll find a way off the island too...",0);
		run_dialog(1);
		set_flag(2,9,1);
	}
break;

